package com.chinairi.mall.controller;


import com.chinairi.common.utils.ResponseUtil;
import com.chinairi.mall.controller.viewobject.ContractMatAllVO;
import com.chinairi.mall.service.IContractMatService;
import com.chinairi.mall.service.modelobject.ViewContractMatMO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.chinairi.common.controller.BaseController;

import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 合同_物料表 前端控制器。
 * </p>
 *
 * @author Webgasd
 * @since 2020-09-03
 */
@RestController
@RequestMapping("/contract-mat")
public class ContractMatController extends BaseController {
    @Autowired
    private IContractMatService iContractMatService;

    @GetMapping("/get")
    @ResponseBody
    public void getList(ViewContractMatMO search) throws IOException {
        List<ViewContractMatMO> list = iContractMatService.getList(search);
        ResponseUtil.showMessage("success", "物料维护列表", list);
    }

    @GetMapping("/updateMatQty")
    @ResponseBody
    public void updateMatQty(ViewContractMatMO viewContractMatMO) throws IOException {
        iContractMatService.updateMatQty(viewContractMatMO);
        ResponseUtil.showMessage("success", "年度需求维护成功", null);
    }

    @GetMapping("/selectByMatAllBpList")
    @ResponseBody
    public void selectByMatAllBpList(String code) throws IOException {
        List<ContractMatAllVO> list = iContractMatService.selectByMatAllBpList(code);
        ResponseUtil.showMessage("success", "获取某物料的所有乙方、配额、定价列表成功", list);
    }

    @GetMapping("/updateMatPercentageOrPrice")
    @ResponseBody
    public void updateMatPercentageOrPrice(ContractMatAllVO contractMatAllVO) throws IOException {
        iContractMatService.updateMatPercentageOrPrice(contractMatAllVO);
        ResponseUtil.showMessage("success", "合同配额和价格维护成功", null);
    }
}